<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: vertx/http.js</title>
    
    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">
    
    <h1 class="page-title">Source: vertx/http.js</h1>
    
    


    
    <section>
        <article>
            <pre class="prettyprint source"><code>/*
 * Copyright 2011-2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

if (typeof __vertxload === 'string') {
  throw "Use require() to load Vert.x API modules"
}

/**
 * The http module provides HTTP functions. 
 *
 * @exports vertx/http
 */
var http = {};
var net = require('vertx/net');
var MultiMap = require('vertx/multi_map').MultiMap;

load("vertx/read_stream.js");
load("vertx/write_stream.js");
load("vertx/ssl_support.js");
load("vertx/tcp_support.js");
load("vertx/helpers.js");

/**
 * A &lt;code>BodyHandler&lt;/code> is a {@linkcode Handler} that accepts a
 * {@linkcode module:vertx/buffer~Buffer|Buffer} as it's parameter.
 * @typedef {function} BodyHandler
 * @param {module:vertx/buffer~Buffer} buffer A Buffer object containing the body of the message
 */

/**
 * Create and return a {@linkcode module:vertx/http.HttpServer}
 *
 * @example
 * var http = require('vertx/http');
 * var server = http.createHttpServer();
 *
 * // setup request handlers and such...
 * server.listen(8080, 'localhost');
 *
 * @return {module:vertx/http.HttpServer} the newly created server
 */
http.createHttpServer = function() {
  return new http.HttpServer();
}


/**
 * Create and return a {@linkcode module:vertx/http.HttpClient}
 *
 * @returns {module:vertx/http.HttpClient}
 */
http.createHttpClient = function() {
  return new http.HttpClient();
}

/**
 * Represents a server-side HttpServerRequest object. This object is created internally
 * by vert.x and passed as a parameter to a request listener. It should not be directly
 * created.
 *
 * @example
 * var http    = require('vertx/http');
 * var console = require('vertx/console');
 *
 * var server = http.createHttpServer();
 * server.requestHandler(function(request) {
 *
 *   // Get headers from the HttpServerRequest object
 *   // and write them to the console
 *   for (var k in request.headers()) {
 *     console.log(k + ": " + headers[k]);
 *   }
 * 
 *   request.response.end(str);
 * 
 * }).listen(8080, 'localhost');
 *
 * @class 
 * @param {org.vertx.java.core.http.HttpServerRequest} request the underlying
 * Java HttpServerRequest object
 * @mixes ReadStream
 */
http.HttpServerRequest = function(jreq) {
  var reqHeaders   = null;
  var reqParams    = null;
  var version      = null;
  var reqFormAttrs = null;
  var netSocket    = null;
  var that         = this;

  readStream(this, jreq);

  /**
   * The HTTP version - either HTTP_1_0 or HTTP_1_1
   *
   * @returns {string} version
   */
  this.version = function() {
    if (version === null) {
      version = jreq.version().toString();
    }
    return version;
  }

  /**
   *
   * Get the NetSocket. Primarily for internal use, but if you really must
   * roll your own websockets or some such, this will let you do that.
   * @returns {module:vertx/net.NetSocket} The raw &lt;code>NetSocket&lt;/code>.
   */
  this.netSocket = function() {
    if (netSocket === null) {
      netSocket = new net.NetSocket(jreq.netSocket());
    }
    return netSocket;
  }

  /**
   * The HTTP method, one of HEAD, OPTIONS, GET, POST, PUT, DELETE, CONNECT, TRACE
   *
   * @returns {string} The HTTP method
   */
  this.method = function() {
    return jreq.method();
  }

  /**
   * The uri of the request. For example
   * http://www.somedomain.com/path/morepath/resource.foo?param=32&otherparam=x
   *
   * @returns {string} uri
   */
  this.uri = function() {
    return jreq.uri();
  }

  /**
   * The path part of the uri. For example /path/morepath/resource.foo
   *
   * @returns {string} path
   */
  this.path = function() {
    return jreq.path();
  }

  /**
   * The query part of the uri. For example param=32&otherparam=x
   *
   * @returns {string} query
   */
  this.query = function() {
    return jreq.query();
  }

  /**
   * The headers of the request.
   *
   * @returns {module:vertx/multi_map~MultiMap}
   */
  this.headers = function() {
    if (!reqHeaders) {
      reqHeaders = new MultiMap(jreq.headers());
    }
    return reqHeaders;
  }

  /**
   * Return the remote (client side) address of the request
   *
   * @returns {module:vertx/multi_map~MultiMap}
   */
  this.params = function() {
    if (!reqParams) {
      reqParams = new MultiMap(jreq.params());
    }
    return reqParams;
  }

  /**
   * @external java.net.InetSocketAddress
   */

  /**
   * Get the address of the remote peer as a Java InetSocketAddress object
   *
   * @return {java.net.InetSocketAddress} the underlying Java socket address instance
   */
  this.remoteAddress = function() {
    return jreq.remoteAddress();
  }

  /**
   * Get an array of Java X509Certificate objects
   *
   * @return {Array} Array of Java X509Certificate objects
   */
  this.peerCertificateChain = function() {
    return jreq.peerCertificateChain();
  }

  /**
   * Return the absolute URI corresponding to the the HTTP request
   *
   * @returns {string} absoluteURI
   */
  this.absoluteURI = function() {
    return jreq.absoluteURI();
  }

  /**
   * You must call this function with true before receiving the request body if you expect it to
   * contain a multi-part form
   * @param expect
   */
  this.expectMultiPart = function(expect) {
    jreq.expectMultiPart(expect);
    return that;
  }

  /**
   * Return a form attributes object
   *
   * @returns {module:vertx/multi_map~MultiMap} The form attributes
   */
  this.formAttributes = function() {
    if (!reqFormAttrs) {
      reqFormAttrs =  new MultiMap(jreq.formAttributes());
    }
    return reqFormAttrs;
  }

  /**
   * Set the upload handler. The handler will get notified once a new file
   * upload was received and so allow to get notified by the upload in
   * progress.
   *
   * @param {UploadHandler} handler The handler to call
   * @returns {module:vertx/http.HttpServerRequest} this
   */
  this.uploadHandler = function(handler) {
    if (handler) {
      jreq.uploadHandler(wrapUploadHandler(handler));
    }
    return that;
  }

  /**
   *  Set the body handler for this request, the handler receives a single
   *  Buffer object as a parameter.  This can be used as a decorator.
   *
   * @param {BodyHandler} handler The handler to call once the body was received
   * @returns {module:vertx/http.HttpServerRequest} this
   */
  this.bodyHandler = function(handler) {
    jreq.bodyHandler(handler);
    return that;
  }

  var jresp = jreq.response();

  /**
   * @property {module:vertx/http.HttpServerResponse} response A response object
   * that can be used to send a response to this request.
   */
  this.response = new http.HttpServerResponse(jresp);

  /**
   * @private
   */
  this._to_java_request = function() {
    return jreq;
  }
}

/**
 * &lt;p>
 * A server-side HTTP response.
 * An instance of this class is created and associated to every instance of
 * {@linkcode module:vertx/http.HttpServerRequest} that is created.
 * &lt;/p>
 *
 * &lt;p>
 * It allows the developer to control the HTTP response that is sent back to
 * the client for a partcular HTTP request. It contains methods that allow HTTP
 * headers and trailers to be set, and for a body to be written out to the
 * response.  
 * &lt;/p>
 *
 * @class
 * @param {org.vertx.java.core.http.HttpServerResponse} jresp the underlying java proxy
 * @mixes WriteStream
 */
http.HttpServerResponse = function(jresp) {
  var that = this;
  var respHeaders = null;
  var respTrailers = null;

  /**
   * Get or set HTTP status code of the response.
   * @param {number} [code] The HTTP status code, e.g. 200
   * @returns {number|module:vertx/http.HttpServerResponse} If a status code is supplied, this method
   * sets it and returns itself. If a status code is not provided, return the current
   * status code for this response.
   */
  this.statusCode = function(code) {
    if (code) {
      jresp.setStatusCode(code);
      return that;
    } else {
      return jresp.getStatusCode();
    }
  }

  /**
   * Get or set HTTP status message of the response.
   * @param {string} [message] The HTTP status message.
   * @returns {string|module:vertx/http.HttpServerResponse} 
   */
  this.statusMessage = function(msg) {
    if (msg) {
      jresp.setStatusMessage(msg);
      return that;
    } else {
      return jresp.getStatusMessage();
    }
  }

  /**
   * Get or set if the response is chunked
   * @param {boolean} [chunked] Whether or not the response will be chunked encoding
   * @returns {boolean|module:vertx/http.HttpServerResponse}
   */
  this.chunked = function(ch) {
    if (ch) {
      jresp.setChunked(ch);
      return that;
    } else {
      return jresp.isChunked();
    }
  }

  /**
   * Return the http headers of the response
   * @returns {module:vertx/multi_map~MultiMap}
   */
  this.headers = function() {
    if (!respHeaders) {
      respHeaders = new MultiMap(jresp.headers());
    }
    return respHeaders;
  }

  /**
   * Put a header on the response.
   *
   * @param {string} headerName The name under which the header should be stored
   * @param {string} headerValue T the value of the header
   * @returns {module:vertx/http.HttpServerResponse}
   */
  this.putHeader = function(k, v) {
    jresp.putHeader(k, v);
    return that;
  }

  /**
   * Return the trailing headers of the response
   *
   * @returns {module:vertx/multi_map~MultiMap}
   */
  this.trailers = function() {
    if (!respTrailers) {
      respTrailers = new MultiMap(jresp.trailers());
    }
    return respTrailers;
  }

  /**
   * Put a trailing header
   *
   * @param {string} trailerName The name under which the header should be stored
   * @param {string} trailerValue The value of the trailer
   * @returns {module:vertx/http.HttpServerResponse}
   */
  this.putTrailer = function(k, v) {
    jresp.putTrailer(k, v);
    return that;
  }

  /**
   * Write content to the response
   *
   * @param {string} body The body of the response.
   * @param {string} [encoding] The character encoding, defaults to UTF-8
   * @returns {module:vertx/http.HttpServerResponse} Returns self
   */
  this.write = function(body, encoding) {
    if (encoding === undefined) {
      jresp.write(body);
    } else {
      jresp.write(body, encoding);
    }
    return that;
  }

  /**
   * Forces the head of the request to be written before end is called on the
   * request. This is normally used to implement HTTP 100-continue handling,
   * see continue_handler for more information.
   *
   * @returns {module:vertx/http.HttpServerResponse}
   */
  this.sendHead = function() {
    jresp.sendHead();
    return that;
  }

  /**
   * &lt;p>
   * Ends the response. If no data has been written to the response body,
   * the actual response won't get written until this method gets called.
   * &lt;/p>
   * &lt;p>
   * Once the response has ended, it cannot be used any more.
   * &lt;/p>
   *
   * @param {string} [chunk] a string to write to the data stream before closing
   * @param {string} [encoding] the encoding to use for the write (default is UTF-8)
   */
  this.end = function(arg0, arg1) {
    if (arg0) {
      if (arg1) {
        jresp.end(arg0, arg1);
      } else {
        jresp.end(arg0);
      }
    } else {
      jresp.end();
    }
  }

  /**
   * Tell the kernel to stream a file directly from disk to the outgoing
   * connection, bypassing userspace altogether (where supported by the
   * underlying operating system. This is a very efficient way to serve
   * files.
   *
   * @param {string} fileName Path to file to send.
   * @param {string} notFoundFile Path to a file to send if &lt;code>fileName&lt;/code> can't be found.
   * @returns {module:vertx/http.HttpServerResponse}
   */
  this.sendFile = function(fileName, notFoundFile) {
    if (notFoundFile === undefined) {
      jresp.sendFile(fileName);
    } else {
      jresp.sendFile(fileName, notFoundFile);
    }
    return that;
  }

  writeStream(that, jresp);
}

/**
 * Represents an upload from an HTML form. Created internally and provided to upload
 * handlers. Instances of this class should not be created externally.
 *
 * @constructor
 * @param {org.vertx.java.core.http.HttpServerFileUpload} jupload the underlying java proxy object
 * @see UploadHandler
 * @mixes ReadStream
 */
http.HttpServerFileUpload = function(jupload) {
  readStream(this, jupload);
  /**
   * Stream the upload to the given file
   *
   * @param {string} filename The file to which it wil be streamed
   * @returns {http.HttpServerFileUpload}
   */
  this.streamToFileSystem = function(filename) {
    jupload.streamToFileSystem(filename);
    return this;
  };

  /**
   * The filename of the upload
   *
   * @returns {string} filenmae
   */
  this.filename = function() {
    return jupload.filename();
  };

  /**
   * The name of the upload
   *
   * @returns {string} name
   */
  this.name = function() {
    return jupload.name();
  };

  /**
   * The content type
   *
   * @returns {string} contentType
   */
  this.contentType = function() {
    return jupload.contentType();
  };

  /**
   * The content transfer encoding
   *
   * @returns {string} contentTransferEncoding
   */
  this.contentTransferEncoding = function() {
    return jupload.contentTransferEncoding();
  }

  /**
   * The charset
   *
   * @returns {string} charset
   */
  this.charset = function() {
    return jupload.charset().toString();
  }

  /**
   * The size
   *
   * @returns {number} size
   */
  this.size = function() {
    return jupload.size();
  }

}

/**
 * An &lt;code>UploadHandler&lt;/code> is a {@linkcode Handler} that accepts a
 * {@linkcode module:vertx/http.HttpServerFileUpload|HttpServerFileUpload} 
 * object as it's parameter. This allows server code to handle and process
 * uploaded files from HTTP clients.
 * @typedef {function} UploadHandler
 * @param {module:vertx/http.HttpServerFileUpload} upload The file being uploaded
 */
var wrapUploadHandler = function(handler) {
  return function(jupload) {
    handler(new http.HttpServerFileUpload(jupload));
  }
}

/**
 * &lt;p>Represents an HTML 5 Websocket&lt;/p>
 * &lt;p>Instances of this class are created and provided to the handler of an
 * {@linkcode HttpClient} when a successful websocket connect attempt occurs.&lt;/p>
 * &lt;p>It implements both {@linkcode ReadStream} and {@linkcode WriteStream} so
 * it can be used with {@linkcode module:vertx/Pump~Pump|Pump} to pump data
 * with flow control.&lt;/p>
 *
 * @constructor
 *
 * @param {org.vertx.java.core.http.WebSocketBase} jWebSocket The java WebSocketBase object
 * @param {boolean} [server] whether this is a server-side websocket (default: false)
 * @see WebSocketHandler
 * @mixes ReadStream
 * @mixes WriteStream
 */
http.WebSocket = function(jwebsocket, server) {
  var headers = null;
  readStream(this, jwebsocket);
  writeStream(this, jwebsocket);

  /**
   * When a WebSocket is created it automatically registers an event handler
   * with the eventbus, the ID of that handler is returned.
   *
   * Given this ID, a different event loop can send a binary frame to that
   * event handler using the event bus and that buffer will be received by
   * this instance in its own event loop and written to the underlying
   * connection. This allows you to write data to other websockets which are
   * owned by different event loops.
   *
   * @returns {string} id
   */
  this.binaryHandlerID = function() {
    return jwebsocket.binaryHandlerID();
  };

  /**
   * When a WebSocket is created it automatically registers an event handler
   * with the eventbus, the ID of that handler is returned.
   *
   * Given this ID, a different event loop can send a text frame to that
   * event handler using the event bus and that buffer will be received by
   * this instance in its own event loop and written to the underlying
   * connection. This allows you to write data to other websockets which are
   * owned by different event loops.
   *
   * @returns {string} id
   */
  this.textHandlerID = function() {
    return jwebsocket.textHandlerID();
  };

  /**
   *  Write data to the websocket as a binary frame
   *
   * @param {module:vertx/buffer~Buffer} data
   */
  this.writeBinaryFrame = function(data) {
    jwebsocket.writeBinaryFrame(data);
  };

  /**
   *  Write data to the websocket as a text frame
   *
   * @param {module:vertx/buffer~Buffer} data
   */
  this.writeTextFrame = function(data) {
    jwebsocket.writeTextFrame(data);
  };

  /**
   * Set a closed {@linkcode Handler} on the connection, the handler receives
   * no parameters.
   *
   * @param {Handler} handler The handler to call when the underlying connection has been closed
   * @returns {WebSocket} this
   */
  this.closeHandler = function(handler) {
    jwebsocket.closeHandler(handler);
    return this;
  };

  /**
   * Close the websocket connection
   */
  this.close = function() {
    jwebsocket.close();
  };

  if (server) {
    /**
     * The path the websocket connect was attempted at.
     * Only available if this is a server websocket.
     *
     * @returns {string} path
     */
    this.path = function() {
      return jwebsocket.path();
    };

    /**
     * Reject the WebSocket. Sends 404 to client
     * Only available if this is a server websocket.
     *
     * @returns {module:vertx/http.WebSocket}
     */
    this.reject = function() {
      jwebsocket.reject();
      return ws;
    }
    /**
     * The headers of the handshake request
     * Only available if this is a server websocket.
     *
     * @returns {module:vertx/multi_map~MultiMap}
     */
    this.headers = function() {
      if (!headers) {
        headers = new MultiMap(jwebsocket.headers());
      }
      return headers;
    }
  }
}

/**
 * An HTTP and websockets server. Created by calling 
 * {@linkcode module:vertx/http.createHttpServer}.
 *
 * @example
 * var http = require('vertx/http');
 * var server = http.createHttpServer();
 *
 * server.requestHandler( function(request) {
 *    // handle the incoming request
 * }
 *
 * server.listen(8000, 'localhost');
 *
 * @class
 * @mixes TCPSupport
 * @mixes ServerTCPSupport
 * @mixes SSLSupport
 * @mixes ServerSSLSupport
 */
http.HttpServer = function() {
  var that = this;
  var jserver = __jvertx.createHttpServer();


  sslSupport(this, jserver);
  serverSslSupport(this, jserver);
  tcpSupport(this, jserver);
  serverTcpSupport(this, jserver);

  /**
   * Set the request handler for the server. As HTTP requests are received by
   * the server, instances of 
   * {@linkcode module:vertx/http.HttpServerRequest|HttpServerRequest} will be created
   * and passed to this handler.
   *
   * @param {RequestHandler} handler the function used to handle the request.
   * @return {module:vertx/http.HttpServer}
   */
  this.requestHandler = function(handler) {
    if (handler) {
      if (typeof handler === 'function') {
        handler = wrappedRequestHandler(handler);
      } else {
        // It's a route matcher
        handler = handler._to_java_handler();
      }
      jserver.requestHandler(handler);
    }
    return that;
  }

  /**
   * Set the websocket handler for the server. If a websocket connect
   * handshake is successful a new 
   * {@linkcode module:vertx/http.WebSocket|WebSocket} instance will be created
   * and passed to the handler.
   * 
   
   * @param {WebSocketHandler} handler the function used to handle the request.
   * @return {module:vertx/http.HttpServer}
   */
  this.websocketHandler = function(handler) {
    if (handler) {
      jserver.websocketHandler(wrappedWebsocketHandler(true, handler));
    }
    return that;
  }

  /**
   * Close the server. If a handler is supplied, it will be called
   * when the underlying connection has completed closing.
   *
   * @param {Handler} [handler] The handler to notify when close() completes
   */
  this.close = function(handler) {
    if (handler) {
      jserver.close(handler);
    } else {
      jserver.close();
    }
  }

  /**
   * Start to listen for incoming HTTP requests
   *
   * @param {number} port The port to listen on
   * @param {string} [host] The host name or IP address
   * @param {Handler} [listenHandler] A handler to be notified when the underlying
   *        system level listen() call has completed.
   * @returns {module:vertx/http.HttpServer}
   */
  this.listen = function() {
    var args = Array.prototype.slice.call(arguments);
    var handler = getArgValue('function', args);
    var host = getArgValue('string', args);
    var port = getArgValue('number', args);
    if (handler) {
      handler = adaptAsyncResultHandler(handler);
    }
    if (host == null) {
      host = "0.0.0.0";
    }
    jserver.listen(port, host, handler);
    return that;
  }

  /**
   * @private
   */
  this._to_java_server = function() {
    return jserver;
  }
}


/**
 * &lt;p>An HTTP client that maintains a pool of connections to a specific host, at a
 * specific port. The client supports pipelining of requests.&lt;/p>
 * &lt;p>As well as HTTP requests, the client can act as a factory for 
 * HTML5 {@linkcode module:vertx/http.WebSocket|websockets}.&lt;/p>
 *
 * @class
 * @mixes TCPSupport
 * @mixes SSLSupport
 * @mixes ClientSSLSupport
 */
http.HttpClient = function() {
  var that = this;
  var jclient = __jvertx.createHttpClient();

  sslSupport(this, jclient);
  clientSslSupport(this, jclient);
  tcpSupport(this, jclient);

  /**
   * Set the exception handler.
   *
   * @param {Handler} handler The handler which is called on an exception
   * @returns {module:vertx/http.HttpClient}
   */
  this.exceptionHandler = function(handler) {
    jclient.exceptionHandler(handler);
    return that;
  }

  /**
   * Get or set the maxium number of connections this client will pool
   *
   * @param {number} [size] the maximum number of connection
   * @returns {number|module:vertx/http.HttpClient}
   */
  this.maxPoolSize = function(size) {
    if (size === undefined) {
      return jclient.getMaxPoolSize();
    } else {
      jclient.setMaxPoolSize(size);
      return that;
    }
  }

  /**
   * &lt;p>
   * Get or set if the client use keep alive. If &lt;code>keepAlive&lt;/code> is
   * &lt;code>true&lt;/code> then, after the request has ended the connection will be
   * returned to the pool where it can be used by another request. In this
   * manner, many HTTP requests can be pipe-lined over an HTTP connection.
   * Keep alive connections will not be closed until the &lt;code>close()&lt;/code>
   * method is invoked.&lt;/p>
   * &lt;p>
   * If &lt;code>keepAlive&lt;/code> is &lt;code>false&lt;/code> then a new connection will
   * be created for each request and it won't ever go in the pool, and the
   * connection will closed after the response has been received. Even with no
   * keep alive, the client will not allow more than &lt;code>getMaxPoolSize()&lt;/code>
   * connections to be created at any one time.&lt;/p> 
   * &lt;p>
   * If &lt;code>keepAlive&lt;/code> is &lt;code>undefined&lt;/code> returns the current
   * keep alive status of this client.
   * &lt;/p>
   *
   * @param {boolean} [keepAlive]
   * @returns {boolean|module:vertx/http.HttpClient}
   */
  this.keepAlive = function(ka) {
    if (ka === undefined) {
      return jclient.isKeepAlive();
    } else {
      jclient.setKeepAlive(ka);
      return that;
    }
  }

  /**
   * Get or set the port that the client will attempt to connect to on the
   * server on. The default value is 80 
   *
   * @param {number} [port] The port to connect on.
   * @returns {number|module:vertx/http.HttpClient}
   */
  this.port = function(p) {
    if (p === undefined) {
      return jclient.getPort();
    } else {
      jclient.setPort(p);
      return that;
    }
  }

  /**
   *  Get or set the host name or ip address that the client will attempt to
   *  connect to on the server on
   *
   * @param {string} [host] The host name or IP address.
   * @returns {string|module:vertx/http.HttpClient}
   */
  this.host = function(h) {
    if (h === undefined) {
      return jclient.getHost();
    } else {
      jclient.setHost(h);
      return that;
    }
  }

  /**
   * Get or set if the host should be verified.  If set then the client will
   * try to validate the remote server's certificate hostname against the
   * requested host. Should default to 'true'.
   * This method should only be used in SSL mode
   *
   * @param {boolean} verify whether or not to verify hosts 
   * @returns {boolean|module:vertx/http.HttpClient}
   */
  this.verifyHost = function(h) {
    if (h === undefined) {
      return jclient.isVerifyHost();
    } else {
      jclient.setVerifyHost(h);
      return that;
    }
  }

  /**
   * Attempt to connect an HTML5 websocket to the specified URI.
   * The connect is done asynchronously and the handler is called with a WebSocket on success.
   *
   * @param {string} uri A relative URI where to connect the websocket on the host, e.g. /some/path
   * @param {WebSocketHandler} handler The handler to be called with the WebSocket
   */
  this.connectWebsocket = function(uri, handler) {
    jclient.connectWebsocket(uri, wrappedWebsocketHandler(false, handler));
  }

  /**
   * This is a quick version of the get method where you do not want to do anything with the request
   * before sing.
   * With this method the request is immediately sent.
   * When an HTTP response is received from the server the handler is called passing in the response.
   *
   * @param {string} uri A relative URI where to perform the GET on the server.
   * @param {ResponseHandler} handler The handler to be called
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.getNow = function(uri, handler) {
    return new http.HttpClientRequest(jclient.getNow(uri, wrapResponseHandler(handler)));
  }

  /**
   * This method returns an request which represents an HTTP OPTIONS request with the specified uri.
   * When an HTTP response is received from the server the handler is called passing in the response.
   *
   * @param {string} uri A relative URI where to perform the OPTIONS on the server.
   * @param {ResponseHandler} handler The handler to be called
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.options = function(uri, handler) {
    return new http.HttpClientRequest(jclient.options(uri, wrapResponseHandler(handler)));
  }

  /**
   * This method returns an request which represents an HTTP GET request with the specified uri.
   * When an HTTP response is received from the server the handler is called passing in the response.
   *
   * @param {string} uri A relative URI where to perform the GET on the server.
   * @param {ResponseHandler} handler The handler to be called
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.get =function(uri, handler) {
    return new http.HttpClientRequest(jclient.get(uri, wrapResponseHandler(handler)));
  }

  /**
   * This method returns an request which represents an HTTP HEAD request with the specified uri.
   * When an HTTP response is received from the server the handler is called passing in the response.
   *
   * @param {string} uri A relative URI where to perform the HEAD on the server.
   * @param {ResponseHandler} handler The handler to be called
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.head =function(uri, handler) {
    return new http.HttpClientRequest(jclient.head(uri, wrapResponseHandler(handler)));
  }

  /**
   * This method returns an request which represents an HTTP POST request with the specified uri.
   * When an HTTP response is received from the server the handler is called passing in the response.
   *
   * @param {string} uri A relative URI where to perform the POST on the server.
   * @param {ResponseHandler} handler The handler to be called
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.post = function(uri, handler) {
    return new http.HttpClientRequest(jclient.post(uri, wrapResponseHandler(handler)));
  }

  /**
   * This method returns an request which represents an HTTP PUT request with the specified uri.
   * When an HTTP response is received from the server the handler is called passing in the response.
   *
   * @param {string} uri A relative URI where to perform the PUT on the server.
   * @param {ResponseHandler} handler The handler to be called
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.put = function(uri, handler) {
    return new http.HttpClientRequest(jclient.put(uri, wrapResponseHandler(handler)));
  }

  /**
   * This method returns an request which represents an HTTP DELETE request with the specified uri.
   * When an HTTP response is received from the server the handler is called passing in the response.
   *
   * @param {string} uri A relative URI where to perform the DELETE on the server.
   * @param {ResponseHandler} handler The handler to be called
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.delete = function(uri, handler) {
    return new http.HttpClientRequest(jclient.delete(uri, wrapResponseHandler(handler)));
  }

  /**
   * This method returns an request which represents an HTTP TRACE request with the specified uri.
   * When an HTTP response is received from the server the handler is called passing in the response.
   *
   * @param {string} uri A relative URI where to perform the TRACE on the server.
   * @param {ResponseHandler} handler The handler to be called
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.trace = function(uri, handler) {
    return new http.HttpClientRequest(jclient.trace(uri, wrapResponseHandler(handler)));
  }

  /**
   * This method returns an request which represents an HTTP CONNECT request with the specified uri.
   * When an HTTP response is received from the server the handler is called passing in the response.
   *
   * @param {string} uri A relative URI where to perform the CONNECT on the server.
   * @param {ResponseHandler} handler The handler to be called
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.connect = function(uri, handler) {
    return new http.HttpClientRequest(jclient.connect(uri, wrapResponseHandler(handler)));
  }

  /**
   * This method returns an request which represents an HTTP PATCH request with the specified uri.
   * When an HTTP response is received from the server the handler is called passing in the response.
   *
   * @param {string} uri A relative URI where to perform the PATCH on the server.
   * @param {ResponseHandler} handler The handler to be called
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.patch = function(uri, handler) {
    return new http.HttpClientRequest(jclient.patch(uri, wrapResponseHandler(handler)));
  }

  /**
   * This method returns an request which represents an HTTP request with the specified uri.
   * When an HTTP response is received from the server the handler is called passing in the response.
   *
   * @param {string} method The HTTP method which is used for the request
   * @param {string} uri A relative URI where to perform the PUT on the server.
   * @param {ResponseHandler} handler The handler to be called
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.request = function(method, uri, handler) {
    return new http.HttpClientRequest(jclient.request(method, uri, wrapResponseHandler(handler)));
  }

  /**
   * Close the client
   */
  this.close = function() {
    jclient.close();
  }

  /**
   * A &lt;code>ResponseHandler&lt;/code> is a {@linkcode Handler} that accepts a
   * {@linkcode module:vertx/http.HttpClientResponse|ClientResponse} 
   * object as it's parameter. 
   * @typedef {function} ResponseHandler
   * @param {module:vertx/http.HttpClientResponse} response The HTTP client response
   */
  var wrapResponseHandler = function(handler) {
    return function(jresp) {
      handler(new http.HttpClientResponse(jresp));
    }
  }

}

/**
 * &lt;p>
 * Represents a client-side HTTP request.  Instances are created by an
 * {@linkcode module:vertx/http.HttpClient} instance, via one of the methods
 * corresponding to the specific HTTP methods, or the generic {@linkcode
 * module:vertx/http.HttpClient#request} method.
 * &lt;/p>
 * &lt;p>
 * Once a request has been obtained, headers can be set on it, and data can be
 * written to its body if required. Once you are ready to send the request, the
 * {@linkcode module:vertx/http.HttpClientRequest#end} method should be called.
 * &lt;/p>
 * &lt;p>
 * The headers of the request are actually sent either when the 
 * {@linkcode module:vertx/http.HttpClientRequest#end} method is called, or,
 * when the first part of the body is written, whichever
 * occurs first.
 * &lt;/p>
 * &lt;p>
 * This class supports both chunked and non-chunked HTTP.
 * It mixes in {@linkcode WriteStream} so it can be used with
 * {@linkcode module:vertx/pump~Pump} to pump data with flow control.
 * &lt;/p>
 * &lt;p>
 * An example of using this class is as follows:
 * &lt;p>
 *
 * @example
 *
 * var console = require('vertx/console');
 *
 * var req = httpClient.post("/some-url", function(response) {
 *     console.log("Got response: " + response.statusCode);
 *   }
 * });
 *
 * req.headers().add("Content-Length", 5);
 * req.end(new Buffer('hello');
 *
 * @constructor
 * @param org.vertx.java.core.http.HttpClientRequest the underlying Java proxy
 * @mixes WriteStream
 */
http.HttpClientRequest = function(jreq) {
  var that = this;
  var reqHeaders = null;
  writeStream(this, jreq);

  /**
   * Sets or gets whether the request should used HTTP chunked encoding or not.
   *
   * @param {boolean} [chunked] If val is true, this request will use HTTP
   * chunked encoding, and each call to write to the body will correspond to a
   * new HTTP chunk sent on the wire. If chunked encoding is used the HTTP
   * header 'Transfer-Encoding' with a value of 'Chunked' will be automatically
   * inserted in the request. If &lt;code>chunked&lt;/code> is not provided, returns
   * the current value.
   * @returns {boolean|module:vertx/http.HttpClientRequest}
   */
  this.chunked = function(ch) {
    if (ch === undefined) {
      return jreq.isChunked();
    } else {
      jreq.setChunked(ch);
      return that;
    }
  }

  /**
   * Returns the headers for the requests
   *
   * @returns {module:vertx/multi_map~MultiMap} The headers
   */
  this.headers = function() {
    if (!reqHeaders) {
      reqHeaders = new MultiMap(jreq.headers());
    }
    return reqHeaders;
  }

  /**
   * Put a header on the request
   *
   * @param {string} name The header name
   * @param {string} value The header value
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.putHeader = function(k, v) {
    jreq.putHeader(k, v);
    return that;
  }

  /**
   * Write to the request body
   * @param {string} chunk the data to write
   * @param {string} [encoding] the data encoding (default is UTF-8)
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.write = function(arg0, arg1) {
    if (arg1 === undefined) {
      jreq.write(arg0);
    } else {
      jreq.write(arg0, arg1);
    }
    return that;
  }

  /**
   * If you send an HTTP request with the header 'Expect' set to the value
   * '100-continue' and the server responds with an interim HTTP response with
   * a status code of '100' and a continue handler has been set using this
   * method, then the handler will be called.  You can then continue to write
   * data to the request body and later end it. This is normally used in
   * conjunction with the send_head method to force the request header to be
   * written before the request has ended.
   *
   * @param {Handler} handler The handler
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.continueHandler = function(handler) {
    jreq.continueHandler(handler);
    return that;
  }

  /**
   * Forces the head of the request to be written before end is called on the
   * request. This is normally used to implement HTTP 100-continue handling.
   *
   * @see module:vertx/http.HttpClientRequest#continue_handler
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.sendHead = function() {
    jreq.sendHead();
    return that;
  }

  /**
   * Ends the request. If no data has been written to the request body, and
   * send_head has not been called then the actual request won't get written
   * until this method gets called.  Once the request has ended, it cannot be
   * used any more, and if keep alive is true the underlying connection will
   * be returned to the HttpClient pool so it can be assigned to another request.
   *
   * @param {string} [chunk] The data to write
   * @param {string} [encoding] The charset to use if data is written
   */
  this.end = function(arg0, arg1) {
    if (arg0) {
      if (arg1) {
        jreq.end(arg0, arg1);
      } else {
        jreq.end(arg0);
      }
    } else {
      jreq.end();
    }
  }

  /**
   * Set's the amount of time after which if a response is not received an exception
   * will be sent to the exception handler of this request. Calling this method more than once
   * has the effect of canceling any existing timeout and starting the timeout from scratch.
   *
   * @param {number} timeout The amount of time in milliseconds to wait before timing out
   * @returns {module:vertx/http.HttpClientRequest}
   */
  this.timeout = function(t) {
    jreq.setTimeout(t);
    return that;
  }
}

/**
 * &lt;p>Represents a client-side HTTP response.
 * An instance is provided to the user via a {@linkcode ResponseHandler}
 * instance that was specified when one of the HTTP method operations, or the
 * generic {@linkcode module:vertx.http.HttpClient#request|request}
 * method was called on an instance of {@linkcode module:vertx/http.HttpClient}.
 * &lt;/p>
 * &lt;p>
 * It mixes in {@linkcode ReadStream} so it can be used with
 * {@linkcode module:vertx/pump~Pump|Pump} to pump data with flow control.
 * &lt;/p>
 * @constructor
 * @param {org.vertx.java.core.http.HttpClientResponse} the underlying Java proxy
 * @see ResponseHandler
 * @mixes ReadStream
 */
http.HttpClientResponse = function(jresp) {
  var that = this;
  var respHeaders = null;
  var respTrailers = null;
  var netSocket    = null;
  readStream(this, jresp)

  /**
   *
   * Get the NetSocket. Primarily for internal use, but if you really must
   * roll your own websockets or some such, this will let you do that.
   * @returns {module:vertx/net.NetSocket} The raw &lt;code>NetSocket&lt;/code>.
   */
  this.netSocket = function() {
    if (netSocket === null) {
      netSocket = new net.NetSocket(jresp.netSocket());
    }
    return netSocket;
  }

  /**
   * The HTTP status code of the response.
   *
   * @returns {number} The HTTP Status code
   */
  this.statusCode = function() {
    return jresp.statusCode();
  }

  /**
   * The HTTP Status message of the response
   *
   * @returns {string} The HTTP Status message
   */
  this.statusMessage = function() {
    return jresp.statusMessage();
  }

  /**
   * Get all the headers of the response.
   *
   * @returns {module:vertx/multi_map~MultiMap} The response headers
   */
  this.headers = function() {
    if (!respHeaders) {
      respHeaders = new MultiMap(jresp.headers());
    }
    return respHeaders;
  }

  /**
   * Get all the trailing headers of the response.
   *
   * @returns {module:vertx/multi_map~MultiMap} The response trailers
   */
  this.trailers = function() {
    if (!respTrailers) {
      respTrailers = new MultiMap(jresp.trailers());
    }
    return respTrailers;
  }

  /**
    * The Set-Cookie headers (including trailers)
   *
   * @returns {Array} The cookies as an array of strings
   */
  this.cookies = function() {
    return jresp.cookies();
  }

  /**
   * Set a handler to receive the entire body in one go - do not use this for large bodies
   *
   * @param {BodyHandler} handler The handler to use
   * @returns {module:vertx/http.HttpClientResponse}
   */
  this.bodyHandler = function(handler) {
    jresp.bodyHandler(handler);
    return that;
  }
}


/**
 * &lt;p>
 * This class allows you to do route requests based on the HTTP verb and the
 * request URI, in a manner similar to &lt;a * href="http://www.sinatrarb.com/">Sinatra&lt;/a> 
 * or &lt;a * href="http://expressjs.com/">Express&lt;/a>.
 * RouteMatcher also lets you extract paramaters from the request URI either a
 * simple pattern or using regular expressions for more complex matches. Any
 * parameters extracted will be added to the requests parameters
 * which will be available to you in your request handler.
 * &lt;/p>
 * &lt;p>
 * It's particularly useful when writing REST-ful web applications.
 * &lt;/p>
 *
 * &lt;p>
 * To use a simple pattern to extract parameters simply prefix the parameter
 * name in the pattern with a ':' (colon).
 * &lt;/p>
 *
 * &lt;p>
 * Different handlers can be specified for each of the HTTP verbs, GET, POST, PUT, DELETE etc.
 * &lt;/p>
 *
 * &lt;p>
 * For more complex matches regular expressions can be used in the pattern.
 * When regular expressions are used, the extracted parameters do not have a
 * name, so they are put into the HTTP request with names of param0, param1,
 * param2 etc.
 * &lt;/p>
 *
 * Multiple matches can be specified for each HTTP verb. In the case there are
 * more than one matching patterns for a particular request, the first matching
 * one will be used.
 *
 * @example
 * var http = require('vertx/http');
 * var server = http.createHttpServer();
 * 
 * var routeMatcher = new http.RouteMatcher();
 * 
 * routeMatcher.get('/animals/dogs', function(req) {
 *     req.response.end('You requested dogs');
 * });
 * 
 * routeMatcher.get('/animals/cats', function(req) {
 *     req.response.end('You requested cats');    
 * });
 * 
 * server.requestHandler(routeMatcher).listen(8080, 'localhost');
 *
 * @constructor
 */
http.RouteMatcher = function() {

  var j_rm = new org.vertx.java.core.http.RouteMatcher();

  this.call = function(req) {
    j_rm.handle(req._to_java_request())
  }

  /**
   * Specify a handler that will be called for a matching HTTP GET
   *
   * @pattern {string} pattern to match
   * @param {RequestHandler} handler handler for match
   * @return {module:vertx/http.RouteMatcher}
   */
  this.get = function(pattern, handler) {
    j_rm.get(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP PUT
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.put = function(pattern, handler) {
    j_rm.put(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP POST
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.post = function(pattern, handler) {
    j_rm.post(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP DELETE
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.delete = function(pattern, handler) {
    j_rm.delete(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP OPTIONS
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.options = function(pattern, handler) {
    j_rm.options(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP HEAD
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.head = function(pattern, handler) {
    j_rm.head(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP TRACE
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.trace = function(pattern, handler) {
    j_rm.trace(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP CONNECT
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.connect = function(pattern, handler) {
    j_rm.connect(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP PATCH
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.patch = function(pattern, handler) {
    j_rm.patch(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP ALL
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.all = function(pattern, handler) {
    j_rm.all(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP GET
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}

   */
  this.getWithRegEx = function(pattern, handler) {
    j_rm.getWithRegEx(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP PUT
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.putWithRegEx = function(pattern, handler) {
    j_rm.putWithRegEx(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP POST
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.postWithRegEx = function(pattern, handler) {
    j_rm.postWithRegEx(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP DELETE
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.deleteWithRegEx = function(pattern, handler) {
    j_rm.deleteWithRegEx(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP PUT
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.optionsWithRegEx = function(pattern, handler) {
    j_rm.optionsWithRegEx(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP HEAD
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.headWithRegEx = function(pattern, handler) {
    j_rm.headWithRegEx(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP TRACE
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.traceWithRegEx = function(pattern, handler) {
    j_rm.traceWithRegEx(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP CONNECT
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.connectWithRegEx = function(pattern, handler) {
    j_rm.connectWithRegEx(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP PATCH
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.patchWithRegEx = function(pattern, handler) {
    j_rm.patchWithRegEx(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for a matching HTTP request
   *
   * @param {string} pattern pattern to match
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.allWithRegEx = function(pattern, handler) {
    j_rm.allWithRegEx(pattern, wrappedRequestHandler(handler));
    return this;
  }

  /**
   * Specify a handler that will be called for HTTP request that not match any pattern.
   *
   * @param {RequestHandler} handler http server request handler
   * @return {module:vertx/http.RouteMatcher}
   */
  this.noMatch = function(handler) {
    j_rm.noMatch(wrappedRequestHandler(handler));
    return this;
  }
  /**
   *
   * @returns {org.vertx.java.core.http.RouteMatcher}
   * @private
   */
  this._to_java_handler = function() {
    return j_rm;
  }
}


/**
 * A &lt;code>WebSocketHandler&lt;/code> is a {@linkcode Handler} that accepts a
 * {@linkcode module:vertx/http.WebSocket|WebSocket} as it's parameter.
 *
 * @typedef {function} WebSocketHandler
 * @param {module:vertx/http.WebSocket} websocket the active {@linkcode module:vertx/http.WebSocket|WebSocket}
 */
function wrappedWebsocketHandler(server, handler) {
  return function(jwebsocket) {
    handler(new http.WebSocket(jwebsocket, server));
  }
}

/**
 * A &lt;code>RequestHandler&lt;/code> is a {@linkcode Handler} that responds to
 * notifications from objects in the &lt;code>vertx/http&lt;/code> module and expects
 * an {@linkcode module:vertx/http.HttpServerRequest|HttpServerRequest} object
 * as its parameter.
 *
 * @example
 * var http = require('vertx/http');
 * var server = http.createHttpServer();
 *
 * server.requestHandler( function( request ) {
 *   // This function is executed for each
 *   // request event on our server
 * } );
 *
 * @see module:vertx/http.HttpServer#requestHandler
 * @typedef {function} RequestHandler
 * @param {message} request The incoming message
 */
function wrappedRequestHandler(handler) {
  return function(jreq) {
    handler(new http.HttpServerRequest(jreq));
  }
}

module.exports = http;

</code></pre>
        </article>
    </section>




</div>

<nav>
    <h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="module-vertx.html">vertx</a></li><li><a href="buffer.html">vertx/buffer</a></li><li><a href="console.html">vertx/console</a></li><li><a href="container.html">vertx/container</a></li><li><a href="event_bus.html">vertx/event_bus</a></li><li><a href="file_system.html">vertx/file_system</a></li><li><a href="http.html">vertx/http</a></li><li><a href="multi_map.html">vertx/multi_map</a></li><li><a href="net.html">vertx/net</a></li><li><a href="parse_tools.html">vertx/parse_tools</a></li><li><a href="pump.html">vertx/pump</a></li><li><a href="shared_data.html">vertx/shared_data</a></li><li><a href="sockjs.html">vertx/sockjs</a></li><li><a href="timer.html">vertx/timer</a></li></ul><h3>Externals</h3><ul><li><a href="InetSocketAddress.html">InetSocketAddress</a></li><li><a href="Buffer_.html">Buffer</a></li><li><a href="RecordParser.html">RecordParser</a></li><li><a href="SockJSSocket.html">SockJSSocket</a></li></ul><h3>Classes</h3><ul><li><a href="buffer-Buffer.html">Buffer</a></li><li><a href="file_system.AsyncFile.html">AsyncFile</a></li><li><a href="http.HttpClient.html">HttpClient</a></li><li><a href="http.HttpClientRequest.html">HttpClientRequest</a></li><li><a href="http.HttpClientResponse.html">HttpClientResponse</a></li><li><a href="http.HttpServer.html">HttpServer</a></li><li><a href="http.HttpServerFileUpload.html">HttpServerFileUpload</a></li><li><a href="http.HttpServerRequest.html">HttpServerRequest</a></li><li><a href="http.HttpServerResponse.html">HttpServerResponse</a></li><li><a href="http.RouteMatcher.html">RouteMatcher</a></li><li><a href="http.WebSocket.html">WebSocket</a></li><li><a href="multi_map-MultiMap.html">MultiMap</a></li><li><a href="net.NetClient.html">NetClient</a></li><li><a href="net.NetServer.html">NetServer</a></li><li><a href="net.NetSocket.html">NetSocket</a></li><li><a href="pump-Pump.html">Pump</a></li><li><a href="sockjs.SockJSServer.html">SockJSServer</a></li></ul><h3>Mixins</h3><ul><li><a href="ClientSSLSupport.html">ClientSSLSupport</a></li><li><a href="ReadStream.html">ReadStream</a></li><li><a href="ServerSSLSupport.html">ServerSSLSupport</a></li><li><a href="ServerTCPSupport.html">ServerTCPSupport</a></li><li><a href="SSLSupport.html">SSLSupport</a></li><li><a href="TCPSupport.html">TCPSupport</a></li><li><a href="WriteStream.html">WriteStream</a></li></ul><h3><a href="global.html">Global</a></h3>
</nav>

<br clear="both">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.0-dev</a> on Wed Jul 17 2013 20:27:22 GMT+0100 (BST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>